﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace _3Dshower
{
    static class ExChange
    {
        public static PointF ChangeFromPoint(this  PointF Goal, Point p)
        {
            //TODO: 这里考虑对点进行转化
            Goal.X=((float)p.Coor[0]+2)*100;
            Goal.Y=((float)p.Coor[1]+2)*100;
            return Goal;
        }
    }
    class drawFace
    {
       public PointF[] points=new PointF[4];
       public Color ThisColor;
       public line[] lines = new line[4];
       public int Number;
    }
    class MyCubeModel:MyModel
    {
        public drawFace[] getDrawFace()
        {//显示BUG
            drawFace[] result = new drawFace[3] { new drawFace(), new drawFace(), new drawFace()};
            PointF temp = new PointF();
            int haveFace = 0;
            for (int i = 0; i < planes.Length; ++i)
            {
                int j;
                if (planes[i].CanShow)
                {
                    for (j = 0; j < planes.Length; ++j)
                    {
                        if (planes[j].CanShow&&i != j )
                        {
                            double? deep = planes[i].pointDeep(planes[j].CenturePoint);//其他面中心点在测试面的深度
                            if (deep.HasValue && deep < planes[j].CenturePoint.Coor[2])
                                break;
                        }
                    }
                    if (j == planes.Length)
                    {
                        result[haveFace].ThisColor = planes[i].color;
                        result[haveFace].points[0] = new PointF();
                        result[haveFace].points[0] = temp.ChangeFromPoint(planes[i].Points[0]);
                        result[haveFace].points[1] = new PointF();
                        result[haveFace].points[1]=temp.ChangeFromPoint(planes[i].Points[1]);
                        result[haveFace].points[2] = new PointF();
                        result[haveFace].points[2] = temp.ChangeFromPoint(planes[i].Points[2]);
                        result[haveFace].points[3] = new PointF();
                        result[haveFace].points[3] = temp.ChangeFromPoint(planes[i].Points[3]);
                        result[haveFace].lines = planes[i].Lines;
                        ++haveFace;
                    }
                    result[0].Number = haveFace;
                }
            } 
            return result;
        }
    }
}
